<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-lx-calendar"></i> 权限管理 </el-breadcrumb-item>
                <el-breadcrumb-item>权限详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="form-box">
                <el-form ref="form" :model="form" label-width="80px">
                    <el-divider content-position="left">权限详情</el-divider>

                    <el-form-item label="权限名称" prop="name">
                        <el-input v-model="form.name" disabled></el-input>
                    </el-form-item>

                    <el-form-item label="权限类型" prop="type">
                       <el-select v-model="form.type" placeholder="类型" disabled>
                            <el-option v-for="(item, index) in types" :key="index" :label="item.name" :value="item.code"> </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="状态">
                        <el-switch v-model="form.status" :active-value="'01'" :inactive-value="'00'" disabled></el-switch>
                    </el-form-item>


                    <el-form-item label="权限描述" prop="description">
                        <el-input type="textarea" rows="5" v-model="form.description" disabled></el-input>
                    </el-form-item>
                     <el-form-item>
                        <el-button @click="goback" icon="el-icon-arrow-left">返回</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'baseform',
    inject: ['reload'],
    data() {
        return {
            id: this.$route.query.id,
            // permissions: [],
            types:[],
            form: {
                name: '',
                type:'',
                status: '',
                description: ''
            }
        };
    },
    created: function () {
        this.getType();
        this.init();
    },
    methods: {
        async init() {
            var a = await this.$http.get('/permission/' + this.id);
            if (a.code == 200) {
                this.form = a.data;
            } else {
                this.$message.error(a.message);
            }
        },
        goback(){
            this.$router.go(-1);
        },
        getType() {
            this.types = JSON.parse(window.sessionStorage.getItem('type'));
        },
        // async getPermission(){
        //     var d = await this.$http.get("/permissionResId/"+this.id);
        //     if(d.code == 200){
        //         this.permissions = d.data;
        //     }
        // },
    }
};
</script>